var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIBase"),
    s = t("UIConfig"),
    c = t("UIManager"),
    p = t("ValueBean"),
    l = t("BaseRoadCatDataCom"),
    d = t("BaseDlgNode"),
    u = t("BoxGift"),
    h = t("CallRoad"),
    f = t("CarMoveCom"),
    y = t("CatMoveCom"),
    v = t("EquipmentCall"),
    g = t("OpenTabCom"),
    m = t("ChangeCom"),
    _ = t("GameEm"),
    C = cc._decorator,
    b = C.ccclass,
    I =
        (C.property,
        C.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.updateLoadSaveTime = 0;
                e.makeBuild = null;
                e.callParent = {road: [], nodeCall: [], equipment: []};
                e.catIndexId = 0;
                e.isStartRun = !1;
                e.canImMakeRoad = 0;
                e.startNpcCount = {};
                e.initNpcStarCount = {};
                e.gitCom = null;
                e.openNodeCom = null;
                e.boxGitfData = {};
                e.evClose = !1;
                e.curViewDlg = null;
                e.lastFoodId = "";
                e.clickArenCloseDlg = !1;
                e.isAddFoodData = !1;
                e.carCsLastTime = 0;
                e.tempCarXCsAren1 = [];
                e.tempCarXCsAren2 = [];
                e.roomCost = "0";
                return e;
            }
            e.prototype.addCost = function () {
                CacheDataManager.addGameC("99999999999999999999999991000000");
            };
            e.prototype.getAngle = function (t, e) {
                return Math.atan((e.y - t.y) / (e.x - t.x));
            };
            e.prototype.overLastGuild = function () {
                var t = GuildCache.checkId,
                    e = GuildCache.oncecheckId,
                    o = GameDataValue.getLastLv();
                for (var a in t)
                    if (parseInt(a) < o)
                        for (var i = t[a], n = 0; n < i.length; n++)
                            GuildCache.isOverGuid(i[n]) || GuildCache.overGuid(i[n]);
                for (var a in e)
                    if (parseInt(a) < o)
                        for (i = e[a], n = 0; n < i.length; n++)
                            GuildCache.isOverOnceGuid(i[n]) || GuildCache.overOnceGuid(i[n]);
            };
            e.prototype.onShowEnd = function () {
                this.overLastGuild();
                QReport.send(6001 + GameDataValue.getLastLv() + "");
                QReport.sendOnce("1008");
                this.makeBuild = new p.default();
                cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
                CacheDataManager.setCoinCount("0");
                CacheDataManager.resetGameTaskOverCount();
                this.updateCof();
                this.addEvent();
                CacheDataManager.updateCostDataView = !0;
                CacheDataManager.updateCostDataView = !1;
                cc.game.on(cc.game.EVENT_HIDE, this.leaveGame.bind(this), this);
                cc.game.on(cc.game.EVENT_SHOW, this.returnGame.bind(this), this);
            };
            e.prototype.returnGame = function () {
                console.log("重新返回游戏");
                this.checkOpenOnLine();
            };
            e.prototype.leaveGame = function () {
                console.log("游戏进入后台");
            };
            e.prototype.checkGuild = function () {
                var t = GameDataValue.getLastLv();
                if (GuildCache.checkId[t])
                    for (var e in GuildCache.checkId[t])
                        if (GuildCache.checkId[t].length > 0) {
                            var o = GuildCache.checkId[t][e];
                            if (!GuildCache.isOverGuid(o)) {
                                this.openGuild(o, null);
                                return;
                            }
                        }
            };
            e.prototype.openGuild = function (t, e) {
                var o = this;
                GuildCache.checkKey = t;
                GuildCache.openGuildView({
                    closeCB: function () {
                        e && e();
                        switch (t) {
                            case GuildCache.checkId[0][0]:
                            case GuildCache.checkId[0][1]:
                                GuildCache.overGuid(t);
                                o.scheduleOnce(function () {
                                    o.checkGuild();
                                });
                                break;
                            case GuildCache.checkId[0][2]:
                                GuildCache.overGuid(t);
                        }
                    }
                });
            };
            e.prototype.onKeyDown = function (t) {
                switch (t.keyCode) {
                    case cc.macro.KEY.a:
                        this.getMapSave();
                }
            };
            e.prototype.getRoadStartCount = function () {
                for (var t = 0, e = 0, o = "", a = 0; a < this.callParent.road.length; a++) {
                    var i = this.callParent.road[a];
                    if (i.changeTip != o) {
                        "" != o && (t = e);
                        o = i.changeTip;
                    }
                    e++;
                }
                return t;
            };
            e.prototype.updateNpcRoadAren = function () {
                var t = CacheDataManager.getNpcLevelAren(GameDataValue.getLastLv()),
                    e = CacheDataManager.getRoadLevelAren(GameDataValue.getLastLv());
                this.makeBuild.setTabAren(t, e);
            };
            e.prototype.updateCof = function () {
                var t = this;
                if (CacheDataManager.isLoadingCof && CacheDataManager.mapIsLoadOver) {
                    this.scheduleOnce(function () {
                        t.resetCallNode();
                        t.resetEquipment();
                        t.updateNpcRoadAren();
                        var e = t.getRoadStartCount();
                        t.makeBuild.resetInit(e, t.callParent.road.length);
                        t.setUnlockInitTab();
                        t.isStartRun = !0;
                        t.scheduleOnce(function () {
                            c.default.open(s.UIID.UITipDlg);
                            GameDataValue.checkNewEquip();
                        }, 1);
                        GameDataValue.haveNewTip() &&
                            t.scheduleOnce(function () {
                                c.default.open(s.UIID.UIGetNewFarm);
                            }, 1);
                        CacheDataManager.updateEquip = !0;
                    }, 0.1);
                    GameDataValue.getLastLv() <= 0 ? (this.canImMakeRoad = 2) : (this.canImMakeRoad = 0);
                    this.loadParseGame();
                    var e = GameDataValue.getLevelData();
                    if (e) {
                        var o = {};
                        for (var a in e) o[a] = e[a];
                        this.checkFirstUnLoad();
                        this.loadingOldParse(o);
                        CacheDataManager.updateCostDataView = !0;
                        this.scheduleOnce(function () {
                            CacheDataManager.updateCostDataView = !0;
                        });
                        this.checkOpenOnLine();
                    }
                    this.updateGift("", 0);
                } else
                    this.scheduleOnce(function () {
                        t.updateCof();
                    });
            };
            e.prototype.checkOpenOnLine = function () {
                var t = GameDataValue.getLevelData().saveTime || 0,
                    e = (Date.now() - t) / 1e3;
                console.log("UIGameData ----------------- offTime", e);
                e > 300 &&
                    this.scheduleOnce(function () {
                        c.default.open(s.UIID.UIOffLine, {offTime: e});
                    }, 0.2);
            };
            e.prototype.loadingOldParse = function (t) {
                t.curLevel;
                var e = t.maxLevel || 0;
                this.makeBuild.setMaxLevelCount(e, 0);
                this.updateLevelPro();
                if (Object.keys(t.npc).length > 1)
                    for (var o in t.npc) {
                        this.startNpcCount[o] || (this.startNpcCount[o] = 0);
                        if ("0" == o) {
                            if ((a = t.npc[o]) > 1) {
                                this.startNpcCount[o] += 1;
                                this.startNpcCount[2] || (this.startNpcCount[2] = 0);
                                this.startNpcCount[2] += a - 1;
                            } else this.startNpcCount[o] += a;
                        } else {
                            var a = t.npc[o];
                            this.startNpcCount[o] += a;
                        }
                    }
                else
                    for (var o in t.npc)
                        if ((a = t.npc[o]) > 1) {
                            this.startNpcCount[1] = a - 1;
                            this.startNpcCount[0] = 1;
                        } else this.startNpcCount[o] = a;
                var i = t.tabUnlockValue;
                for (var o in i) (i[o] || 0 == i[o]) && this.addUnlockTabCount(parseInt(o), i[o]);
                this.makeBuild.parseOldObj(t);
                this.checkNpcCount(t);
                CacheDataManager.setCoinCount(t.cost);
                for (var o in t.taskOverIndex) CacheDataManager.setGameTaskOverCount(o, t.taskOverIndex[o]);
            };
            e.prototype.checkNpcCount = function (t) {
                var e = 0;
                for (var o in t.npc) e += t.npc[o];
                e <= 0 && this.resetNpcCount();
            };
            e.prototype.resetNpcCount = function () {
                var t = this,
                    e = GameDataValue.getLastLv(),
                    o = CacheDataManager.getChapterRoomId(e),
                    a = CacheDataManager.getRestaurant(o, e);
                this.parseEmployeeData(a.mode_path);
                for (var i in this.startNpcCount)
                    this.startNpcCount[i] && (this.initNpcStarCount[i] = this.startNpcCount[i]);
                this.scheduleOnce(function () {
                    var a = CacheDataManager.getTaskSaveData(),
                        i = CacheDataManager.getLevelupgrade(o, e);
                    for (var n in a)
                        if (a[n] && i[n] && 1 == i[n].upgrade_type) {
                            var r = i[n].value1;
                            if (r > 0)
                                for (var s = 0; s < r; s++) {
                                    t.makeBuild.addNpcType("1");
                                    t.startNpcCount[1] = (t.startNpcCount[1] || 0) + 1;
                                }
                            var c = i[n].value2;
                            if (c > 0)
                                for (s = 0; s < c; s++) {
                                    t.makeBuild.addNpcType("2");
                                    t.startNpcCount[2] = (t.startNpcCount[2] || 0) + 1;
                                }
                        }
                });
            };
            e.prototype.getMapSave = function () {
                var t = this.makeBuild.getMapSave();
                GameDataValue.setLevelData(t);
                PlayerData.getSaveData();
            };
            e.prototype.loadParseGame = function () {
                var t = GameDataValue.getLastLv();
                Math.floor(t / 7) % 2 == 0 ? QAudio.playUIStartBgm() : QAudio.playGameBgm();
                var e = CacheDataManager.getChapterRoomId(t),
                    o = CacheDataManager.getRestaurant(e, t);
                this.makeBuild.setMaxLevelCount(o.all_level);
                this.updateLevelPro();
                this.parseEmployeeData(o.mode_path);
                this.parseCustomerType(o.ini_customer_type + "");
                CacheDataManager.setCoinCount(o.ini_coin + "");
            };
            e.prototype.parseEmployeeData = function (t) {
                var e = CacheDataManager.getLevelRoadPath(t),
                    o = "0";
                e && (o = e.centerData ? "0_1" : "0");
                this.parseEmployee(CacheDataManager.getEmployee(), o);
            };
            e.prototype.parseEmployee = function (t, e) {
                var o = e.split("_"),
                    a = {};
                for (var i in t) {
                    a[t[i].type] || (a[t[i].type] = []);
                    a[t[i].type].push(t[i]);
                }
                this.startNpcCount = {};
                for (var n = 0; n < o.length; n++) this.startNpcCount[o[n]] = 1;
                this.makeBuild.setEmployee(a, o);
                this.makeBuild.setBaseNpcCount(o.length);
            };
            e.prototype.parseCustomerType = function (t) {
                var e = t.split("_"),
                    o = CacheDataManager.getCustomer(),
                    a = {};
                for (var i in o)
                    if (o[i] && e.indexOf(o[i].type + "") >= 0) {
                        a[o[i].type] || (a[o[i].type] = []);
                        a[o[i].type].push(o[i]);
                    }
                this.makeBuild.setMakeCatCache({}, a, e);
                "0" == e[0] ? this.makeBuild.setBaseCatCount(e.length) : this.makeBuild.setBaseCarCount(e.length);
            };
            e.prototype.setNodeActive = function (t, e) {
                void 0 === e && (e = !1);
                t && t._touchListener && (t._touchListener.swallowTouches = e);
            };
            e.prototype.loadBuildData = function (t) {
                this.scheduleOnce(function () {
                    t && t();
                }, 0.1);
            };
            e.prototype.reduceNpcBox = function (t, e) {
                this.makeBuild.removeNpcBoxPos(e.id);
                TaskLooper.putPosFoodPos(e);
                this.makeBuild.reduceNpcBox();
            };
            e.prototype.updateCheckView = function () {
                this.makeBuild.setChackTask(!0);
            };
            e.prototype.addEvent = function () {
                EvCat.on(EvCat.reduceNpcBox, this.reduceNpcBox.bind(this), this);
                EvCat.on(EvCat.recCatCall, this.recCatCall.bind(this), this);
                EvCat.on(EvCat.sendSkillTask, this.doSkillTask.bind(this), this);
                EvCat.on(EvCat.updateCheckView, this.updateCheckView.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.upLevelFood, this.uplevelFood.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.taskKind, this.addCatEvent.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.openCarGetNpcFood, this.openCarGetFood.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.addCookTask, this.addCookingData.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.downFood, this.downFood.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.setCookStatus, this.setCookData.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.unlockDevBox, this.unLockDevData.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.roadCatCookTaskOver, this.roadCatCookTaskOver.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.removeTabFood, this.removeFoodData.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.setFoodDevData, this.setDevCoolStatus.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.addNewTempNPC, this.makeNewNpc.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.removeInvate, this.removeNpc.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.removeNpcId, this.removeNpcId.bind(this), this);
                TaskGameEvent.on(TaskGameEvent.roadCatLeave, this.roadCatLeave.bind(this), this);
                this._rect.on(cc.Node.EventType.TOUCH_START, this.clickAren.bind(this), this);
                this.setNodeActive(this._rect);
                EVUIEffView.on(EVUIEffView.openDlg, this.openUIDlg.bind(this), this);
                EVUIEffView.on(EVUIEffView.cacleClose, this.closeData.bind(this), this);
                EVUIEffView.on(EVUIEffView.scrollView, this.updateGift.bind(this), this);
                EVUIEffView.on(EVUIEffView.enableScroll, this.setScroll.bind(this), this);
                this.openOnceGuild();
            };
            e.prototype.makeNewNpc = function (t, e) {
                this.makeBuild.addInvate(e);
            };
            e.prototype.setScroll = function (t, e) {
                this._scroll.$ScrollView.enabled = e;
            };
            e.prototype.removeNpc = function (t, e) {
                this.makeBuild.clearInvateSave(e);
                EvCat.emit(EvCat.removeInvate);
            };
            e.prototype.removeNpcId = function (t, e) {
                this.makeBuild.clearInvateSave(e);
            };
            e.prototype.openOnceGuild = function () {
                if (
                    3 == GameDataValue.getLastLv() &&
                    GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][8]) &&
                    !GuildCache.isOverOnceGuid(GuildCache.oncecheckId[3][0])
                ) {
                    GameDataValue.closeNewTip();
                    GameDataValue.addBuyLockLv();
                    GuildCache.checkKey = GuildCache.oncecheckId[3][0];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[3][0]);
                    this.scheduleOnce(function () {
                        GuildCache.openGuildView();
                    }, 2);
                }
            };
            e.prototype.udpateEeuip = function () {
                var t = CacheDataManager.getCacheCatId();
                "" != t &&
                    EvCat.emit(EvCat.callCat, t, function (t, e) {
                        var o = e.getComponent(y.default);
                        if (o) {
                            CacheDataManager.updateAllAddView();
                            var a = CacheDataManager.getEquipSkinData();
                            o.setEquip(a, a.pos);
                            o.updateViewSkin();
                            CacheDataManager.updateAllAddView();
                        }
                    });
            };
            e.prototype.removeFoodData = function (t, e) {
                EvCat.emit(EvCat.updateFoodView, e.toTab2Index, null, e.toId, !1);
            };
            e.prototype.setDevCoolStatus = function (t, e, o, a) {
                var i = this.makeBuild.getDevIndex(o);
                TaskGameEvent.emit(TaskGameEvent.doFoodDevData, e, i, a);
            };
            e.prototype.roadCatLeave = function (t, e, o, a) {
                if ("0" == a) this.makeBuild.closeWayRoad(e, o);
                else if ("1" == a) {
                    this.makeBuild.resetCarId();
                    this.makeBuild.reduceWaitCount();
                }
                CacheDataManager.canCheckAllMinCs = !0;
                EvCat.emit(EvCat.updateCheckCs, a);
                this.makeBuild.setChackTask(!0);
            };
            e.prototype.doSkillTask = function (t, e, o, a) {
                for (var i in this.initNpcStarCount) this.initNpcStarCount[i] = 0;
                switch (e) {
                    case 0:
                        this.makeBuild.addRoadCat(o);
                        this.makeBuild.addRoadCar(a);
                        break;
                    case 1:
                        if (o)
                            for (var n = 0; n < o; n++) {
                                this.makeBuild.addNpcType("1");
                                this.makeBuild.addNpcCat(1);
                            }
                        if (a)
                            for (n = 0; n < a; n++) {
                                this.makeBuild.addNpcType("2");
                                this.makeBuild.addNpcCat(1);
                            }
                        break;
                    case 2:
                        CacheDataManager.setFoodCdAdd(CacheDataManager.getCheckIdFood(o + "") + "", a);
                        break;
                    case 3:
                        CacheDataManager.addProfitMul(CacheDataManager.getCheckIdFood(o + ""), a);
                        break;
                    case 4:
                        if (o > 0) {
                            CacheDataManager.setAddSpeeds(_.catKind.npcCat, "1", o);
                            CacheDataManager.setAddSpeeds(_.catKind.npcCat, "0", o);
                        }
                        a > 0 && CacheDataManager.setAddSpeeds(_.catKind.npcCat, "2", a);
                        break;
                    case 5:
                        this.addUnlockTabCount(o, a);
                        break;
                    default:
                        console.log("UIGameData ----------------- 未制作功能");
                }
                this.scheduleOnce(function () {
                    CacheDataManager.updateCostDataView = !0;
                });
            };
            e.prototype.addUnlockTabCount = function (t, e) {
                var o = this;
                if (this.openNodeCom) {
                    this.makeBuild.setTabNum(t, e);
                    var a = this.openNodeCom.unLockList;
                    this.checkLock(a, t - 1);
                } else
                    this.scheduleOnce(function () {
                        o.addUnlockTabCount(t, e);
                    }, 0.5);
            };
            e.prototype.checkLock = function (t, e) {
                var o = this,
                    a = e;
                if (t[a]) {
                    var i = t[a].active;
                    t[a].active = !0;
                    if (i != t[a].active) {
                        var n = t[a];
                        if (!this.boxGitfData[a]) {
                            n.scale = 0;
                            var r = this.makeBuild.getTabDataBool(a);
                            this.playGiftBox(
                                t[a].parent,
                                cc.v2(t[a].position),
                                function () {
                                    n.runAction(cc.sequence([cc.scaleTo(0.1, 1.2), cc.scaleTo(0.1, 1)]));
                                    o.setUnlockTabNpc(a);
                                    var t = o.makeBuild.getTabNum(a + 1);
                                    o.makeBuild.setTabNum(e + 1, 0);
                                    o.makeBuild.addRoadCat(t);
                                    o.makeBuild.setTabDataBool(a);
                                },
                                r
                            );
                            this.boxGitfData[a] = !0;
                        }
                    }
                }
            };
            e.prototype.setUnlockInitTab = function () {
                if (this.callParent.road.length > 0)
                    for (
                        var t = this.callParent.road[this.callParent.road.length - 1].changeTip, e = 0;
                        e < this.callParent.road.length;
                        e++
                    ) {
                        var o = this.callParent.road[e];
                        t == o.changeTip && 0 == o.unlockIndex && this.makeBuild.setRoadWayStatus(e, !0);
                    }
            };
            e.prototype.setUnlockTabNpc = function (t) {
                for (var e = t + 1, o = 0; o < this.callParent.road.length; o++)
                    this.callParent.road[o].unlockIndex == e && this.makeBuild.setRoadWayStatus(o, !0);
            };
            e.prototype.playGiftBox = function (t, e, o, a) {
                var i = this;
                if (!a) {
                    var n = this.setLooperNode(QLooperNode.tag_boxDevGift, t, e);
                    if (!n) {
                        this.scheduleOnce(function () {
                            i.playGiftBox(t, e, o, a);
                        }, 0.2);
                        return;
                    }
                    var r = n.getComponent(u.default);
                    r.play(o);
                    return r;
                }
                o && o(t.convertToWorldSpaceAR(e));
                return null;
            };
            e.prototype.setLooperNode = function (t, e, o) {
                var a = QLooperNode.getNode(t);
                if (a) {
                    a.parent = e;
                    a.setPosition(o);
                    return a;
                }
            };
            e.prototype.closeData = function () {
                this.evClose = !0;
            };
            e.prototype.checkClose = function () {
                this.clickArenCloseDlg = !1;
                if (this.evClose) this.evClose = !1;
                else if (this.curViewDlg) {
                    this.curViewDlg.closeView();
                    QLooperNode.putNode(this.curViewDlg.node);
                    this.curViewDlg = null;
                }
            };
            e.prototype.roadCatCookTaskOver = function (t, e, o, a, i, n) {
                void 0 === a && (a = 1);
                void 0 === i && (i = cc.Vec2.ZERO);
                void 0 === n && (n = 1);
                var r = CacheDataManager.getCoinCount(),
                    s = CacheDataManager.getAdMul() * CacheDataManager.getAllPayCount() * a,
                    c = CacheDataManager.getMulProfit(o + "", CacheDataManager.getFoodLevel(o), s);
                r = CacheDataManager.addCost(r, c);
                CacheDataManager.setCoinCount(r);
                CacheDataManager.updateCostDataView = !0;
                EvCat.emit(EvCat.addFoodCoin, i, c, n);
            };
            e.prototype.openUIDlg = function (t, e, o, a, i) {
                this.checkClose();
                if (i || this.lastFoodId != e) {
                    this.lastFoodId = e;
                    switch (o) {
                        case _.DlgKind.unLockDlg:
                            this.openTipNode(QLooperNode.tag_unLockDlg, a);
                            break;
                        case _.DlgKind.uplevel:
                            this.openTipNode(QLooperNode.tag_upLevelDlg, a);
                    }
                }
            };
            e.prototype.openTipNode = function (t, e) {
                var o = QLooperNode.getNode(t);
                o.parent = this.node;
                var a = CacheDataManager.boxLimitePos(cc.v2(this.node.convertToNodeSpaceAR(e)), 150);
                o.setPosition(a);
                CacheDataManager.dlgPos = cc.v2(o.position);
                this.curViewDlg = o.getComponent(d.default);
                this.curViewDlg.openView(this.lastFoodId);
            };
            e.prototype.setCookData = function (t, e, o) {
                o || this.makeBuild.setDevUseStatus(e, !1);
            };
            e.prototype.unLockDevData = function (t, e, o) {
                this.makeBuild.setFoodDevIndexStatus(e, o, !1);
            };
            e.prototype.recCatCall = function (t, e, o) {
                e == _.catKind.roadCat &&
                    ("0" == o ? this.makeBuild.recCurRoadCatCount() : "1" == o && this.makeBuild.recCurRoadCarCount());
            };
            e.prototype.downFood = function (t, e, o, a, i, n, r, s, c, p) {
                var l = cc.v2(this.callParent.road[a].node.position);
                CacheDataManager.flowerCatMove = null;
                this.makeBuild.addCookingOver(c, s, e, o, a, i, n, r, l, p);
            };
            e.prototype.addCookingData = function (t, e, o) {
                var a = this;
                EvCat.emit(EvCat.callCat, o, function (t, i) {
                    a.checkFirstUnLoad();
                    var n = i.getComponent(l.default),
                        r = a.makeBuild.getCookFoodKind(n.getFoodData());
                    EvCat.emit(EvCat.readCatWantFood, o, r.foodKindCountList);
                    a.makeBuild.addTabFoodTask(e, r, o, n.getKindIndex() + "");
                });
            };
            e.prototype.checkFirstUnLoad = function () {
                if (this.makeBuild.checkLoadFood()) {
                    this.checkGuild();
                    EVUIEffView.emit(EVUIEffView.firstDlgEv);
                    CacheDataManager.canSave = !0;
                    this.makeBuild.unLockFoodLvKey("0");
                    CacheDataManager.updateDataSave();
                    this.resetEquipDataFood();
                }
            };
            e.prototype.uplevelFood = function (t, e, o) {
                void 0 === o && (o = !0);
                this.makeBuild.updateFoodLv(e);
                CacheDataManager.updateCostDataView = !0;
                if (o) {
                    this.clickArenCloseDlg = !0;
                    this.evClose = !1;
                }
                CacheDataManager.updateDataSave();
            };
            e.prototype.eventLoad = function () {};
            e.prototype.addCatEvent = function (t, e, o, a, i) {
                e == _.catKind.roadCat
                    ? this.doRoadKindEvent(o, i.index, i.cs, a, i.task)
                    : e == _.catKind.npcCat && this.doNpcKindEvent(o, i.index, a, i.task);
            };
            e.prototype.openCarGetFood = function (t, e, o, a, i) {
                e == _.catKind.roadCat && this.doOpenRoadKindEvent(o, i.index, i.cs, a, i.task);
            };
            e.prototype.doOpenRoadKindEvent = function (t, e, o, a, i) {
                switch (i) {
                    case _.Cat0Index.waitFood:
                        this.makeBuild.setCarCookData(!0);
                }
            };
            e.prototype.doRoadKindEvent = function (t, e, o, a, i) {
                switch (i) {
                    case _.Cat0Index.waitFood:
                    case _.Cat0Index.waitMove:
                        this.makeBuild.addRoadCatWait(t, e, o, a);
                }
            };
            e.prototype.clickAren = function () {
                this.clickArenCloseDlg = !0;
            };
            e.prototype.doNpcKindEvent = function (t, e, o, a) {
                switch (a) {
                    case _.Cat0Index.continueWait:
                        this.makeBuild.setNpcIdStatus(t, a, o);
                }
            };
            e.prototype.onCloseStart = function () {
                cc.game.off(cc.game.EVENT_HIDE, this.leaveGame.bind(this), this);
                cc.game.off(cc.game.EVENT_SHOW, this.returnGame.bind(this), this);
                c.default.closeUiByUIID(s.UIID.UITipDlg);
                GuildCache.closeGuildView();
                cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
                EvCat.offTarget(this);
                TaskGameEvent.offTarget(this);
                EVUIEffView.offTarget(this);
                this._rect.off(cc.Node.EventType.TOUCH_START, this.clickAren.bind(this), this);
                CacheDataManager.resetGameTaskOverCount();
            };
            e.prototype.resetCallNode = function () {
                var t = this,
                    e = [],
                    o = [],
                    a = [];
                EVUIEffView.emit(EVUIEffView.callNode, _.CookingCallKey.lockNode, 0, function (e) {
                    var o = e.getComponent(g.default);
                    o && (t.openNodeCom = o);
                });
                EVUIEffView.emit(EVUIEffView.callRoad, _.CookingCallKey.catTable, 0, function (t) {
                    for (var o = t.getComponent(h.default), a = 0; a < o.callRoadList.length; a++)
                        e.push(o.callRoadList[a].getComponent(m.default));
                });
                this.callParent.road = e;
                EVUIEffView.emit(EVUIEffView.callEquipment, _.CookingCallKey.equipment, 0, function (t) {
                    var e = t.getComponent(v.default);
                    e && o.push(e);
                });
                this.callParent.equipment = o;
                this.resetEquipDataFood();
                this.addGiftData();
                EVUIEffView.emit(EVUIEffView.callNode, _.CookingCallKey.way, 0, function (t) {
                    a.push(t);
                });
                this.callParent.nodeCall = a;
            };
            e.prototype.resetEquipDataFood = function () {
                var t = this.makeBuild.getCurDevFoodData();
                if (this.callParent.equipment.length > 0 && t.length && !this.isAddFoodData) {
                    var e = {};
                    this.isAddFoodData = !0;
                    for (var o = 0; o < this.callParent.equipment.length; o++)
                        for (var a = o; a < this.callParent.equipment.length; a++)
                            if (this.callParent.equipment[o].checkId > this.callParent.equipment[a].checkId) {
                                var i = this.callParent.equipment[o];
                                this.callParent.equipment[o] = this.callParent.equipment[a];
                                this.callParent.equipment[a] = i;
                            }
                    if (this.callParent.equipment.length == t.length) {
                        var n = this.callParent.equipment.length;
                        for (o = 0; o < n; o++) {
                            var r = this.callParent.equipment[o];
                            e[r.checkId] = t[o];
                            r.resetSprite(t[o]);
                            this.makeBuild.setDevAren(t[o], r.aren);
                            for (a = 0; a < r.cookViewDirIndex.length; a++)
                                this.makeBuild.setFoodDir(t[o], a, r.cookViewDirIndex[a]);
                        }
                    } else console.log("UIGameData ----------------- allFoodList.length  设备长度不一致");
                    CacheDataManager.setCheckIdToFoodIdObj(e);
                    CacheDataManager.updateCostDataView = !0;
                }
            };
            e.prototype.addGiftData = function () {
                var t = this;
                EVUIEffView.emit(EVUIEffView.callGiftCom, function (e) {
                    t.gitCom || (t.gitCom = {});
                    t.gitCom[e.giftIndex] = e;
                });
            };
            e.prototype.updateGift = function (t, e) {
                e > 1900 && (CacheDataManager.flowerCatMove = this._scroll.$ScrollView);
            };
            e.prototype.resetEquipment = function () {};
            e.prototype.checkMakeNextCat = function () {
                var t = this.makeBuild.getWayCountIndex(),
                    e = this.makeBuild.getRoadCatData();
                if (t.index >= 0 && e) {
                    this.makeBuild.resetNewCatTime();
                    this.makeBuild.addCurCatCount();
                    var o = this.makeBuild.getWayTask(t.index, t.cs, e.kindIndex + "");
                    if (this.canImMakeRoad > 0 && o[0]) {
                        for (var a = [], i = o[0].path.length - 1; i < o[0].path.length; i++) a.push(o[0].path[i]);
                        o[0].path = a;
                    }
                    this.catIndexId++;
                    EvCat.emit(EvCat.makeCat0, _.catKind.roadCat, e, this.catIndexId, o);
                    CacheDataManager.updateDataSave();
                }
                TaskLooper.putRoadCsIndex(t);
            };
            e.prototype.checkMakeNextCar = function () {
                var t = this.makeBuild.getWayCountIndex(),
                    e = this.makeBuild.getRoadCarData();
                if (t.index >= 0 && e) {
                    this.makeBuild.resetNewCatTime();
                    this.makeBuild.addCurCarCount();
                    var o = this.makeBuild.getCarWayTask(t.index, t.cs, e.kindIndex + "");
                    this.catIndexId++;
                    EvCat.emit(EvCat.makeCar0, _.catKind.roadCat, e, this.catIndexId, o);
                    CacheDataManager.updateDataSave();
                }
                TaskLooper.putRoadCsIndex(t);
            };
            e.prototype.makeInvate = function () {
                if (this.callParent) {
                    if (!this.gitCom) {
                        this.addGiftData();
                        return;
                    }
                    var t = this.makeBuild.getMakeInvate();
                    if (!t) return;
                    var e = this.makeBuild.getMakeTabIndexKey(t.kindIndex + "");
                    if (!this.gitCom[e]) {
                        this.addGiftData();
                        return;
                    }
                    var o = this.getKind(t.kindIndex + ""),
                        a = this.initNpcStarCount[o] || 0;
                    "0" != t.kindIndex && a++;
                    var i = this.makeBuild.getNewNpcBoxPos(this.gitCom[e], t.kindIndex, a);
                    this.catIndexId++;
                    var n = this.makeBuild.addNpcInvateCount(this.catIndexId);
                    CacheDataManager.updateInvateAddTion(this.catIndexId, t.invData);
                    var r = this.initNpcStarCount[o] || 0;
                    this.initNpcStarCount[o] = r + 1;
                    EvCat.emit(EvCat.makeCat2, _.catKind.npcCat, this.catIndexId, t.kindIndex, t, i, n, !0);
                }
            };
            e.prototype.checkMakeNpcNewCat = function () {
                if (this.callParent) {
                    if (!this.gitCom) {
                        this.addGiftData();
                        return;
                    }
                    var t = this.makeBuild.getNpcCatData();
                    if (!t) return;
                    var e = this.makeBuild.getMakeTabIndexKey(t.kindIndex + "");
                    if (!this.gitCom[e]) {
                        this.addGiftData();
                        return;
                    }
                    CacheDataManager.updateDataSave();
                    var o = this.getKind(t.kindIndex + ""),
                        a = (this.initNpcStarCount[o] || 0) + this.makeBuild.getArenCount(o);
                    this.makeBuild.addArenCount(o);
                    var i = this.makeBuild.getNewNpcBoxPos(this.gitCom[e], t.kindIndex, a);
                    this.catIndexId++;
                    var n = this.makeBuild.addNpcCount(this.catIndexId);
                    "0" == t.kindIndex && this.makeBuild.addFirstCat(this.catIndexId);
                    CacheDataManager.updateDataSave();
                    EvCat.emit(
                        EvCat.makeCat1,
                        _.catKind.npcCat,
                        this.catIndexId,
                        t.kindIndex,
                        t,
                        i,
                        n,
                        this.startNpcCount[t.kindIndex] > 0
                    );
                    this.startNpcCount[t.kindIndex] > 0 && this.startNpcCount[t.kindIndex]--;
                }
            };
            e.prototype.getKind = function (t) {
                return "1" == t ? t : "0";
            };
            e.prototype.checkNpcWaitTask = function () {
                var t = this.makeBuild.getMoveToDlgNpcId();
                if (t > 0) {
                    EvCat.emit(EvCat.callCat, t, this.startSendWaitTask.bind(this));
                    CacheDataManager.updateDataSave();
                }
            };
            e.prototype.startSendWaitTask = function (t, e) {
                if (e) {
                    var o = this.makeBuild.getWaitNpcTask(),
                        a = o.catId,
                        i = o.road,
                        n = o.cs,
                        r = o.aren,
                        s = this.makeBuild.getNpcMoveToDlgTask(i, n, a, cc.v2(e.position), r),
                        c = this.makeBuild.getNpcDlgTask(i, n, a, r, t),
                        p = this.makeBuild.getNpcContinueWaitTask(r);
                    this.makeBuild.setNpcIdStatus(t, _.Cat0Index.moveToDlg, "");
                    EvCat.emit(EvCat.addCatTask, t, s, !1);
                    EvCat.emit(EvCat.addCatTask, t, c, !1);
                    EvCat.emit(EvCat.addCatTask, t, p, !0);
                    TaskLooper.putRoadObj(o);
                }
            };
            e.prototype.doCooking = function () {};
            e.prototype.checkNpcCookTask = function () {
                var t = this.makeBuild.getTabFoodDataTask();
                if (t.length > 0) {
                    var e = t.pop();
                    this.makeBuild.setNpcIdStatus(e, _.Cat0Index.moveWalk, "");
                    CacheDataManager.updateDataSave();
                    for (var o = 0; o < t.length; o++) EvCat.emit(EvCat.addCatTask, e, t[o], o == t.length - 1);
                }
            };
            e.prototype.checkRoadCatGetFood = function () {
                var t = this.makeBuild.getWaitFoodEvData();
                if (t) {
                    var e = t.catData.tabIndex,
                        o = cc.v2(this.callParent.road[e].node.position);
                    EvCat.emit(EvCat.readCatWantFood, t.catData.catId, t.catData.viewIdCount);
                    var a = t.catData.foodData.foodKindCountList[t.foodIndex].id,
                        i = this.makeBuild.resetWaitFoodCount(t.catData, t.foodIndex);
                    TaskGameEvent.emit(TaskGameEvent.roadCatCookTaskOver, t.catData.catId, a, t.mul, o, i ? e : -1);
                    i && this.makeBuild.recCookingData(t.catData.catId);
                    QAudio.play(QAudio.ui_get);
                    TaskLooper.putRoadCatGetFood(t);
                    CacheDataManager.updateDataSave();
                }
            };
            e.prototype.update = function (t) {
                if (this.canImMakeRoad > 0 && this.makeBuild.canEnterNextCat()) {
                    this.checkMakeNextCat();
                    this.canImMakeRoad--;
                    this.canImMakeRoad > 0 && this.makeBuild.addNewCatTime(4);
                } else if (this.isStartRun) {
                    this.makeBuild.canEnterNextCat() ? this.checkMakeNextCat() : this.makeBuild.addNewCatTime(t);
                    this.makeBuild.canEnterNextCar() ? this.checkMakeNextCar() : this.makeBuild.addNewCatTime(t);
                    if (this.makeBuild.canMakeNpcBox()) {
                        this.checkMakeNpcNewCat();
                        this.makeBuild.setChackTask(!0);
                    }
                    if (this.makeBuild.invateDataCount()) {
                        this.makeInvate();
                        this.makeBuild.setChackTask(!0);
                    }
                    if (this.makeBuild.npcCheckBool()) {
                        this.makeBuild.setChackTask(!1);
                        if (this.makeBuild.canWaitNpcTask()) {
                            this.checkNpcWaitTask();
                            this.makeBuild.setChackTask(!0);
                        }
                        if (this.makeBuild.canCookingRoadCat()) {
                            this.checkNpcCookTask();
                            this.makeBuild.setChackTask(!0);
                        }
                        if (this.makeBuild.getTabRewardList()) {
                            this.checkRoadCatGetFood();
                            this.makeBuild.setChackTask(!0);
                        }
                        if (this.makeBuild.haveCanUEQTab()) {
                            this.checkTabFoodData();
                            this.makeBuild.setChackTask(!0);
                        }
                        this.makeBuild.changeTabData() && this.makeBuild.setChackTask(!0);
                    }
                    if (CacheDataManager.canCheckAllMinCs && Date.now() - this.carCsLastTime > 500) {
                        this.carCsLastTime = Date.now();
                        CacheDataManager.canCheckAllMinCs = !1;
                        this.checkAllCar();
                    }
                    if (this.makeBuild.canUnLockFood()) {
                        this.checkAddFoodKind();
                        this.makeBuild.setChackTask(!0);
                    }
                    if (CacheDataManager.updateCostDataView) {
                        CacheDataManager.updateCostDataView = !1;
                        EVUIEffView.emit(EVUIEffView.checkCostUI);
                    }
                    this.clickArenCloseDlg && this.checkClose();
                    this.evClose = !1;
                    if (CacheDataManager.isUpdateWear) {
                        CacheDataManager.isUpdateWear = !1;
                        this.udpateEeuip("");
                    }
                    if (CacheDataManager.isUpdateNextSave) {
                        CacheDataManager.isUpdateNextSave = !1;
                        this.getMapSave();
                    }
                    if (CacheDataManager.isUpdateRed) {
                        CacheDataManager.isUpdateRed = !1;
                        CacheDataManager.setRedData(_.RedEm.skillTask, CacheDataManager.haveCanUpLevelSkill());
                        var e = CacheDataManager.checkCost(CacheDataManager.getCoinCount(), this.roomCost + ""),
                            o = this.makeBuild.getMaxLevel(),
                            a = this.makeBuild.getCurLevel();
                        CacheDataManager.setRedData(_.RedEm.gameTask, e && a >= o);
                        EVUIEffView.emit(EVUIEffView.checkRed);
                    }
                    if (CacheDataManager.updateEquip) {
                        CacheDataManager.updateEquip = !1;
                        CacheDataManager.canMerageData = CacheDataManager.canMerage();
                        CacheDataManager.setRedData(
                            _.RedEm.newEquip,
                            GameDataValue.canWearStatus() || CacheDataManager.canMerageData
                        );
                        CacheDataManager.setRedData(_.RedEm.merageEquip, CacheDataManager.canMerageData);
                    }
                }
            };
            e.prototype.checkAllCar = function () {
                var t = this;
                this.tempCarXCsAren1.length = 0;
                this.tempCarXCsAren2.length = 0;
                EvCat.emit(EvCat.callKindCat, _.catKind.roadCat, "1", function (e) {
                    var o = e.getComponent(f.default);
                    o &&
                        ("0" == o.getCarWayAren()
                            ? t.tempCarXCsAren1.push(o)
                            : "1" == o.getCarWayAren() && t.tempCarXCsAren2.push(o));
                });
                this.tempCarXCsAren1 = this.sortCsAren(this.tempCarXCsAren1);
                this.tempCarXCsAren2 = this.sortCsAren(this.tempCarXCsAren2);
                this.checkCsAren(this.tempCarXCsAren1);
                this.checkCsAren(this.tempCarXCsAren2);
                this.tempCarXCsAren2.length > 0 && this.makeBuild.setCarRoadId(this.tempCarXCsAren2[0].getId());
            };
            e.prototype.sortCsAren = function (t) {
                for (var e = 0; e < t.length; e++)
                    for (var o = e + 1; o < t.length; o++)
                        if (t[e].getMoveCs() > t[o].getMoveCs()) {
                            var a = t[e];
                            t[e] = t[o];
                            t[o] = a;
                        }
                return t;
            };
            e.prototype.checkCsAren = function (t) {
                for (var e = 0; e < t.length; e++) t[e].getMoveCs() != e && t[e].resetCsMove(e);
            };
            e.prototype.checkTabFoodData = function () {
                var t = this.makeBuild.getMoveToChangeFoodNpcId();
                if (t >= 0) {
                    CacheDataManager.updateDataSave();
                    EvCat.emit(EvCat.callCat, t, this.changeTabFood.bind(this));
                }
            };
            e.prototype.changeTabFood = function (t, e) {
                var o = this.makeBuild.getTabData();
                if (o) {
                    for (var a = this.makeBuild.parseChangeFood(o, cc.v2(e.position)), i = 0; i < a.length; i++)
                        EvCat.emit(EvCat.addCatTask, t, a[i], i == a.length - 1);
                    this.makeBuild.setNpcIdStatus(t, _.Cat0Index.moveGetFoodData, "");
                    TaskLooper.putWaitFoodObj(o);
                }
            };
            e.prototype.checkAddFoodKind = function () {
                var t = this.makeBuild.getNewUnLockFoodKey();
                if ("" != t) {
                    var e = this.makeBuild.addUnlockFood(t),
                        o = this.makeBuild.getFoodIndexData(t),
                        a = this.makeBuild.getUnLockDev(o),
                        i = CacheDataManager.getGetStarCountData(o, e);
                    EVUIEffView.emit(EVUIEffView.upLevelCooking, o, a, i);
                    this.updateLevelPro();
                    this.checkAddFoodKind();
                    CacheDataManager.updateDataSave();
                }
            };
            e.prototype.updateLevelPro = function () {
                var t = this.makeBuild.getMaxLevel(),
                    e = this.makeBuild.getCurLevel();
                this._progress.$ProgressBar.progress = e / t;
                e >= t
                    ? SpriteView.setSpritePath(this._progress.$Sprite, "Common_Progress_Gauge_Max")
                    : SpriteView.setSpritePath(this._progress.$Sprite, "Common_Progress_Gauge");
                var o = CacheDataManager.getChapterRoomId(GameDataValue.getLastLv()),
                    a = CacheDataManager.getRestaurant(o, GameDataValue.getLastLv()),
                    i = this.getCost(a);
                this.roomCost = i;
                CacheDataManager.isUpdateRed = !0;
                e >= t && CacheDataManager.setCanUpLevel(!0);
            };
            e.prototype.getCost = function (t) {
                for (var e = t.up_cost, o = t.up_cost2, a = 0; a < o; a++) e += "0";
                return e;
            };
            return n([b], e);
        })(r.default));
o.default = I;
